<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="存货编码" prop="cinvcode">
        <el-input
          v-model="queryParams.cinvcode"
          placeholder="请输入存货编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存货代码" prop="cinvaddcode">
        <el-input
          v-model="queryParams.cinvaddcode"
          placeholder="请输入存货代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存货名称" prop="cinvname">
        <el-input
          v-model="queryParams.cinvname"
          placeholder="请输入存货名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存货类别编码" prop="cvencode">
        <el-input
          v-model="queryParams.cvencode"
          placeholder="请输入存货类别编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['basic/inventory:inventory:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['basic/inventory:inventory:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['basic/inventory:inventory:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['basic/inventory:inventory:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="inventoryList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="jcInventoryoid" />
      <el-table-column label="存货编码" align="center" prop="cinvcode" />
      <el-table-column label="存货代码" align="center" prop="cinvaddcode" />
      <el-table-column label="存货名称" align="center" prop="cinvname" />
      <el-table-column label="规格型号" align="center" prop="cinvstd" />
      <el-table-column label="存货类别编码" align="center" prop="cvencode" />
      <el-table-column label="替换件" align="center" prop="creplaceitem" />
      <el-table-column label="是否销售" align="center" prop="bsale" />
      <el-table-column label="是否外购" align="center" prop="bpurchase" />
      <el-table-column label="是否自制" align="center" prop="bself" />
      <el-table-column label="是否生产耗用" align="center" prop="bcomsume" />
      <el-table-column label="是否在制" align="center" prop="bproducing" />
      <el-table-column label="是否应税劳务" align="center" prop="bservice" />
      <el-table-column label="是否成套件" align="center" prop="baccessary" />
      <el-table-column label="税率" align="center" prop="itaxrate" />
      <el-table-column label="单位重量" align="center" prop="iinvweight" />
      <el-table-column label="单位体积" align="center" prop="ivolume" />
      <el-table-column label="计划单价" align="center" prop="iinvrcost" />
      <el-table-column label="参考成本" align="center" prop="iinvsprice" />
      <el-table-column label="参考售价" align="center" prop="iinvscost" />
      <el-table-column label="最低售价" align="center" prop="iinvlscost" />
      <el-table-column label="最新成本" align="center" prop="iinvncost" />
      <el-table-column label="提前期" align="center" prop="iinvadvance" />
      <el-table-column label="经济批量" align="center" prop="iinvbatch" />
      <el-table-column label="安全库存量" align="center" prop="isafenum" />
      <el-table-column label="最高库存" align="center" prop="itopsum" />
      <el-table-column label="最低库存" align="center" prop="ilowsum" />
      <el-table-column label="积压标准" align="center" prop="ioverstock" />
      <el-table-column label="存货ABC分类" align="center" prop="cinvabc" />
      <el-table-column label="是否保质期管理" align="center" prop="binvquality" />
      <el-table-column label="是否批次管理" align="center" prop="binvbatch" />
      <el-table-column label="是否受托代销" align="center" prop="binventrust" />
      <el-table-column label="是否受托代销" align="center" prop="binvoverstock" />
      <el-table-column label="启用日期" align="center" prop="dsdate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dsdate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="停用日期" align="center" prop="dedate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dedate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="自定义项" align="center" prop="bfree1" />
      <el-table-column label="自定义项" align="center" prop="bfree2" />
      <el-table-column label="扣重方式" align="center" prop="cinvdefine1" />
      <el-table-column label="化验指示" align="center" prop="cinvdefine2" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine3" />
      <el-table-column label="自动编号" align="center" prop="iId" />
      <el-table-column label="是否折扣" align="center" prop="binvtype" />
      <el-table-column label="最高进价" align="center" prop="iinvmpcost" />
      <el-table-column label="质量要求说明" align="center" prop="cquality" />
      <el-table-column label="零售单价" align="center" prop="iinvsalecost" />
      <el-table-column label="一级批发价" align="center" prop="iinvscost1" />
      <el-table-column label="二级批发价" align="center" prop="iinvscost2" />
      <el-table-column label="三级批发价" align="center" prop="iinvscost3" />
      <el-table-column label="结算顺序" align="center" prop="bfree3" />
      <el-table-column label="自定义项" align="center" prop="bfree4" />
      <el-table-column label="自定义项" align="center" prop="bfree5" />
      <el-table-column label="自定义项" align="center" prop="bfree6" />
      <el-table-column label="自定义项" align="center" prop="bfree7" />
      <el-table-column label="自定义项" align="center" prop="bfree8" />
      <el-table-column label="自定义项" align="center" prop="bfree9" />
      <el-table-column label="自定义项" align="center" prop="bfree10" />
      <el-table-column label="订货点" align="center" prop="fsubscribepoint" />
      <el-table-column label="平均耗用量" align="center" prop="fvagquantity" />
      <el-table-column label="计价方式" align="center" prop="cvaluetype" />
      <el-table-column label="是否为固定换算率" align="center" prop="bfixexch" />
      <el-table-column label="出库超额上限" align="center" prop="foutexcess" />
      <el-table-column label="入库超额上限" align="center" prop="finexcess" />
      <el-table-column label="保质期天数" align="center" prop="imassdate" />
      <el-table-column label="保质期预警天数" align="center" prop="iwarndays" />
      <el-table-column label="费用率" align="center" prop="fexpensesexch" />
      <el-table-column label="是否出库跟踪入库" align="center" prop="btrack" />
      <el-table-column label="是否有序列号管理" align="center" prop="bserial" />
      <el-table-column label="是否条形码管理" align="center" prop="bbarcode" />
      <el-table-column label="所属权限组" align="center" prop="iid" />
      <el-table-column label="扫码" align="center" prop="cbarcode" />
      <el-table-column label="存货类别" align="center" prop="cinvdefine4" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine5" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine6" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine7" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine8" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine9" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine10" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine11" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine12" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine13" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine14" />
      <el-table-column label="自定义项" align="center" prop="cinvdefine15" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.cinvdefine15, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="自定义项" align="center" prop="cinvdefine16" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.cinvdefine16, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计量单位组类别" align="center" prop="igrouptype" />
      <el-table-column label="计量单位组编码" align="center" prop="cgroupcode" />
      <el-table-column label="计量单位" align="center" prop="ccomunitcode" />
      <el-table-column label="辅计量单位编码" align="center" prop="casscomunitcode" />
      <el-table-column label="销售默认计量单位编码" align="center" prop="csacomunitcode" />
      <el-table-column label="采购默认计量单位编码" align="center" prop="cpucomunitcode" />
      <el-table-column label="库存默认计量单位编码" align="center" prop="cstcomunitcode" />
      <el-table-column label="成本默认计量单位编码" align="center" prop="ccacomunitcode" />
      <el-table-column label="盘点周期单位" align="center" prop="cfrequency" />
      <el-table-column label="盘点周期" align="center" prop="ifrequency" />
      <el-table-column label="盘点日" align="center" prop="idays" />
      <el-table-column label="上次盘点日期" align="center" prop="dlastdate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dlastdate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合理损耗率" align="center" prop="iwastage" />
      <el-table-column label="是否单独存放" align="center" prop="bsolitude" />
      <el-table-column label="生产企业" align="center" prop="centerprise" />
      <el-table-column label="产地" align="center" prop="caddress" />
      <el-table-column label="批准文号或注册证号" align="center" prop="cfile" />
      <el-table-column label="注册商标" align="center" prop="clabel" />
      <el-table-column label="合格证号" align="center" prop="ccheckout" />
      <el-table-column label="生产许可证号" align="center" prop="clicence" />
      <el-table-column label="是否特殊药品" align="center" prop="bspecialties" />
      <el-table-column label="仓　　库" align="center" prop="cdefwarehouse" />
      <el-table-column label="最高售价" align="center" prop="ihighprice" />
      <el-table-column label="销售加成率" align="center" prop="iexpsalerate" />
      <el-table-column label="价格组" align="center" prop="cpricegroup" />
      <el-table-column label="销售贡献等级" align="center" prop="coffergrade" />
      <el-table-column label="发货核销顺序" align="center" prop="iofferrate" />
      <el-table-column label="cMonth" align="center" prop="cmonth" />
      <el-table-column label="iAdvanceDate" align="center" prop="iadvancedate" />
      <el-table-column label="cCurrencyName" align="center" prop="ccurrencyname" />
      <el-table-column label="cProduceAddress" align="center" prop="cproduceaddress" />
      <el-table-column label="cProduceNation" align="center" prop="cproducenation" />
      <el-table-column label="cRegisterNo" align="center" prop="cregisterno" />
      <el-table-column label="cEnterNo" align="center" prop="centerno" />
      <el-table-column label="cPackingType" align="center" prop="cpackingtype" />
      <el-table-column label="cEnglishName" align="center" prop="cenglishname" />
      <el-table-column label="bPropertyCheck" align="center" prop="bpropertycheck" />
      <el-table-column label="cPreparationType" align="center" prop="cpreparationtype" />
      <el-table-column label="cCommodity" align="center" prop="ccommodity" />
      <el-table-column label="iRecipeBatch" align="center" prop="irecipebatch" />
      <el-table-column label="cNotPatentName" align="center" prop="cnotpatentname" />
      <el-table-column label="pubufts" align="center" prop="pubufts" />
      <el-table-column label="bPromotSales" align="center" prop="bpromotsales" />
      <el-table-column label="iPlanPolicy" align="center" prop="iplanpolicy" />
      <el-table-column label="iROPMethod" align="center" prop="iropmethod" />
      <el-table-column label="iBatchRule" align="center" prop="ibatchrule" />
      <el-table-column label="fBatchIncrement" align="center" prop="fbatchincrement" />
      <el-table-column label="iAssureProvideDays" align="center" prop="iassureprovidedays" />
      <el-table-column label="iTestStyle" align="center" prop="iteststyle" />
      <el-table-column label="iDTMethod" align="center" prop="idtmethod" />
      <el-table-column label="fDTRate" align="center" prop="fdtrate" />
      <el-table-column label="fDTNum" align="center" prop="fdtnum" />
      <el-table-column label="cDTUnit" align="center" prop="cdtunit" />
      <el-table-column label="iDTStyle" align="center" prop="idtstyle" />
      <el-table-column label="iQTMethod" align="center" prop="iqtmethod" />
      <el-table-column label="存货分类OID" align="center" prop="jcInventoryclassoid" />
      <el-table-column label="货位档案OID" align="center" prop="jcPositionoid" />
      <el-table-column label="集团大类编码" align="center" prop="jtdlbm" />
      <el-table-column label="集团小类编码" align="center" prop="jtxlbm" />
      <el-table-column label="集团小类代码" align="center" prop="jtxldm" />
      <el-table-column label="排序" align="center" prop="sort" />
      <el-table-column label="使用标识" align="center" prop="sybs" />
      <el-table-column label="集团删除标识" align="center" prop="jtdel" />
      <el-table-column label="集团结算代码" align="center" prop="jtjsdm" />
      <el-table-column label="集团小类代码1" align="center" prop="jtxldm1" />
      <el-table-column label="焦煤财务煤种大类代码" align="center" prop="jmcwmzdldm" />
      <el-table-column label="焦煤财务煤种代码" align="center" prop="jmcwmzdm" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['basic/inventory:inventory:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['basic/inventory:inventory:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改存货档案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="主键" prop="jcInventoryoid">
          <el-input v-model="form.jcInventoryoid" placeholder="请输入主键" />
        </el-form-item>
        <el-form-item label="存货编码" prop="cinvcode">
          <el-input v-model="form.cinvcode" placeholder="请输入存货编码" />
        </el-form-item>
        <el-form-item label="存货代码" prop="cinvaddcode">
          <el-input v-model="form.cinvaddcode" placeholder="请输入存货代码" />
        </el-form-item>
        <el-form-item label="存货名称" prop="cinvname">
          <el-input v-model="form.cinvname" placeholder="请输入存货名称" />
        </el-form-item>
        <el-form-item label="规格型号" prop="cinvstd">
          <el-input v-model="form.cinvstd" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="存货类别编码" prop="cvencode">
          <el-input v-model="form.cvencode" placeholder="请输入存货类别编码" />
        </el-form-item>
        <el-form-item label="替换件" prop="creplaceitem">
          <el-input v-model="form.creplaceitem" placeholder="请输入替换件" />
        </el-form-item>
        <el-form-item label="是否销售" prop="bsale">
          <el-input v-model="form.bsale" placeholder="请输入是否销售" />
        </el-form-item>
        <el-form-item label="是否外购" prop="bpurchase">
          <el-input v-model="form.bpurchase" placeholder="请输入是否外购" />
        </el-form-item>
        <el-form-item label="是否自制" prop="bself">
          <el-input v-model="form.bself" placeholder="请输入是否自制" />
        </el-form-item>
        <el-form-item label="是否生产耗用" prop="bcomsume">
          <el-input v-model="form.bcomsume" placeholder="请输入是否生产耗用" />
        </el-form-item>
        <el-form-item label="是否在制" prop="bproducing">
          <el-input v-model="form.bproducing" placeholder="请输入是否在制" />
        </el-form-item>
        <el-form-item label="是否应税劳务" prop="bservice">
          <el-input v-model="form.bservice" placeholder="请输入是否应税劳务" />
        </el-form-item>
        <el-form-item label="是否成套件" prop="baccessary">
          <el-input v-model="form.baccessary" placeholder="请输入是否成套件" />
        </el-form-item>
        <el-form-item label="税率" prop="itaxrate">
          <el-input v-model="form.itaxrate" placeholder="请输入税率" />
        </el-form-item>
        <el-form-item label="单位重量" prop="iinvweight">
          <el-input v-model="form.iinvweight" placeholder="请输入单位重量" />
        </el-form-item>
        <el-form-item label="单位体积" prop="ivolume">
          <el-input v-model="form.ivolume" placeholder="请输入单位体积" />
        </el-form-item>
        <el-form-item label="计划单价" prop="iinvrcost">
          <el-input v-model="form.iinvrcost" placeholder="请输入计划单价" />
        </el-form-item>
        <el-form-item label="参考成本" prop="iinvsprice">
          <el-input v-model="form.iinvsprice" placeholder="请输入参考成本" />
        </el-form-item>
        <el-form-item label="参考售价" prop="iinvscost">
          <el-input v-model="form.iinvscost" placeholder="请输入参考售价" />
        </el-form-item>
        <el-form-item label="最低售价" prop="iinvlscost">
          <el-input v-model="form.iinvlscost" placeholder="请输入最低售价" />
        </el-form-item>
        <el-form-item label="最新成本" prop="iinvncost">
          <el-input v-model="form.iinvncost" placeholder="请输入最新成本" />
        </el-form-item>
        <el-form-item label="提前期" prop="iinvadvance">
          <el-input v-model="form.iinvadvance" placeholder="请输入提前期" />
        </el-form-item>
        <el-form-item label="经济批量" prop="iinvbatch">
          <el-input v-model="form.iinvbatch" placeholder="请输入经济批量" />
        </el-form-item>
        <el-form-item label="安全库存量" prop="isafenum">
          <el-input v-model="form.isafenum" placeholder="请输入安全库存量" />
        </el-form-item>
        <el-form-item label="最高库存" prop="itopsum">
          <el-input v-model="form.itopsum" placeholder="请输入最高库存" />
        </el-form-item>
        <el-form-item label="最低库存" prop="ilowsum">
          <el-input v-model="form.ilowsum" placeholder="请输入最低库存" />
        </el-form-item>
        <el-form-item label="积压标准" prop="ioverstock">
          <el-input v-model="form.ioverstock" placeholder="请输入积压标准" />
        </el-form-item>
        <el-form-item label="存货ABC分类" prop="cinvabc">
          <el-input v-model="form.cinvabc" placeholder="请输入存货ABC分类" />
        </el-form-item>
        <el-form-item label="是否保质期管理" prop="binvquality">
          <el-input v-model="form.binvquality" placeholder="请输入是否保质期管理" />
        </el-form-item>
        <el-form-item label="是否批次管理" prop="binvbatch">
          <el-input v-model="form.binvbatch" placeholder="请输入是否批次管理" />
        </el-form-item>
        <el-form-item label="是否受托代销" prop="binventrust">
          <el-input v-model="form.binventrust" placeholder="请输入是否受托代销" />
        </el-form-item>
        <el-form-item label="是否受托代销" prop="binvoverstock">
          <el-input v-model="form.binvoverstock" placeholder="请输入是否受托代销" />
        </el-form-item>
        <el-form-item label="启用日期" prop="dsdate">
          <el-date-picker clearable
            v-model="form.dsdate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择启用日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="停用日期" prop="dedate">
          <el-date-picker clearable
            v-model="form.dedate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择停用日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree1">
          <el-input v-model="form.bfree1" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree2">
          <el-input v-model="form.bfree2" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="扣重方式" prop="cinvdefine1">
          <el-input v-model="form.cinvdefine1" placeholder="请输入扣重方式" />
        </el-form-item>
        <el-form-item label="化验指示" prop="cinvdefine2">
          <el-input v-model="form.cinvdefine2" placeholder="请输入化验指示" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine3">
          <el-input v-model="form.cinvdefine3" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自动编号" prop="iId">
          <el-input v-model="form.iId" placeholder="请输入自动编号" />
        </el-form-item>
        <el-form-item label="最高进价" prop="iinvmpcost">
          <el-input v-model="form.iinvmpcost" placeholder="请输入最高进价" />
        </el-form-item>
        <el-form-item label="质量要求说明" prop="cquality">
          <el-input v-model="form.cquality" placeholder="请输入质量要求说明" />
        </el-form-item>
        <el-form-item label="零售单价" prop="iinvsalecost">
          <el-input v-model="form.iinvsalecost" placeholder="请输入零售单价" />
        </el-form-item>
        <el-form-item label="一级批发价" prop="iinvscost1">
          <el-input v-model="form.iinvscost1" placeholder="请输入一级批发价" />
        </el-form-item>
        <el-form-item label="二级批发价" prop="iinvscost2">
          <el-input v-model="form.iinvscost2" placeholder="请输入二级批发价" />
        </el-form-item>
        <el-form-item label="三级批发价" prop="iinvscost3">
          <el-input v-model="form.iinvscost3" placeholder="请输入三级批发价" />
        </el-form-item>
        <el-form-item label="结算顺序" prop="bfree3">
          <el-input v-model="form.bfree3" placeholder="请输入结算顺序" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree4">
          <el-input v-model="form.bfree4" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree5">
          <el-input v-model="form.bfree5" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree6">
          <el-input v-model="form.bfree6" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree7">
          <el-input v-model="form.bfree7" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree8">
          <el-input v-model="form.bfree8" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree9">
          <el-input v-model="form.bfree9" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="bfree10">
          <el-input v-model="form.bfree10" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="订货点" prop="fsubscribepoint">
          <el-input v-model="form.fsubscribepoint" placeholder="请输入订货点" />
        </el-form-item>
        <el-form-item label="平均耗用量" prop="fvagquantity">
          <el-input v-model="form.fvagquantity" placeholder="请输入平均耗用量" />
        </el-form-item>
        <el-form-item label="是否为固定换算率" prop="bfixexch">
          <el-input v-model="form.bfixexch" placeholder="请输入是否为固定换算率" />
        </el-form-item>
        <el-form-item label="出库超额上限" prop="foutexcess">
          <el-input v-model="form.foutexcess" placeholder="请输入出库超额上限" />
        </el-form-item>
        <el-form-item label="入库超额上限" prop="finexcess">
          <el-input v-model="form.finexcess" placeholder="请输入入库超额上限" />
        </el-form-item>
        <el-form-item label="保质期天数" prop="imassdate">
          <el-input v-model="form.imassdate" placeholder="请输入保质期天数" />
        </el-form-item>
        <el-form-item label="保质期预警天数" prop="iwarndays">
          <el-input v-model="form.iwarndays" placeholder="请输入保质期预警天数" />
        </el-form-item>
        <el-form-item label="费用率" prop="fexpensesexch">
          <el-input v-model="form.fexpensesexch" placeholder="请输入费用率" />
        </el-form-item>
        <el-form-item label="是否出库跟踪入库" prop="btrack">
          <el-input v-model="form.btrack" placeholder="请输入是否出库跟踪入库" />
        </el-form-item>
        <el-form-item label="是否有序列号管理" prop="bserial">
          <el-input v-model="form.bserial" placeholder="请输入是否有序列号管理" />
        </el-form-item>
        <el-form-item label="是否条形码管理" prop="bbarcode">
          <el-input v-model="form.bbarcode" placeholder="请输入是否条形码管理" />
        </el-form-item>
        <el-form-item label="所属权限组" prop="iid">
          <el-input v-model="form.iid" placeholder="请输入所属权限组" />
        </el-form-item>
        <el-form-item label="扫码" prop="cbarcode">
          <el-input v-model="form.cbarcode" placeholder="请输入扫码" />
        </el-form-item>
        <el-form-item label="存货类别" prop="cinvdefine4">
          <el-input v-model="form.cinvdefine4" placeholder="请输入存货类别" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine5">
          <el-input v-model="form.cinvdefine5" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine6">
          <el-input v-model="form.cinvdefine6" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine7">
          <el-input v-model="form.cinvdefine7" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine8">
          <el-input v-model="form.cinvdefine8" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine9">
          <el-input v-model="form.cinvdefine9" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine10">
          <el-input v-model="form.cinvdefine10" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine11">
          <el-input v-model="form.cinvdefine11" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine12">
          <el-input v-model="form.cinvdefine12" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine13">
          <el-input v-model="form.cinvdefine13" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine14">
          <el-input v-model="form.cinvdefine14" placeholder="请输入自定义项" />
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine15">
          <el-date-picker clearable
            v-model="form.cinvdefine15"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择自定义项">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="自定义项" prop="cinvdefine16">
          <el-date-picker clearable
            v-model="form.cinvdefine16"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择自定义项">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计量单位组编码" prop="cgroupcode">
          <el-input v-model="form.cgroupcode" placeholder="请输入计量单位组编码" />
        </el-form-item>
        <el-form-item label="计量单位" prop="ccomunitcode">
          <el-input v-model="form.ccomunitcode" placeholder="请输入计量单位" />
        </el-form-item>
        <el-form-item label="辅计量单位编码" prop="casscomunitcode">
          <el-input v-model="form.casscomunitcode" placeholder="请输入辅计量单位编码" />
        </el-form-item>
        <el-form-item label="销售默认计量单位编码" prop="csacomunitcode">
          <el-input v-model="form.csacomunitcode" placeholder="请输入销售默认计量单位编码" />
        </el-form-item>
        <el-form-item label="采购默认计量单位编码" prop="cpucomunitcode">
          <el-input v-model="form.cpucomunitcode" placeholder="请输入采购默认计量单位编码" />
        </el-form-item>
        <el-form-item label="库存默认计量单位编码" prop="cstcomunitcode">
          <el-input v-model="form.cstcomunitcode" placeholder="请输入库存默认计量单位编码" />
        </el-form-item>
        <el-form-item label="成本默认计量单位编码" prop="ccacomunitcode">
          <el-input v-model="form.ccacomunitcode" placeholder="请输入成本默认计量单位编码" />
        </el-form-item>
        <el-form-item label="盘点周期单位" prop="cfrequency">
          <el-input v-model="form.cfrequency" placeholder="请输入盘点周期单位" />
        </el-form-item>
        <el-form-item label="盘点周期" prop="ifrequency">
          <el-input v-model="form.ifrequency" placeholder="请输入盘点周期" />
        </el-form-item>
        <el-form-item label="盘点日" prop="idays">
          <el-input v-model="form.idays" placeholder="请输入盘点日" />
        </el-form-item>
        <el-form-item label="上次盘点日期" prop="dlastdate">
          <el-date-picker clearable
            v-model="form.dlastdate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择上次盘点日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="合理损耗率" prop="iwastage">
          <el-input v-model="form.iwastage" placeholder="请输入合理损耗率" />
        </el-form-item>
        <el-form-item label="是否单独存放" prop="bsolitude">
          <el-input v-model="form.bsolitude" placeholder="请输入是否单独存放" />
        </el-form-item>
        <el-form-item label="生产企业" prop="centerprise">
          <el-input v-model="form.centerprise" placeholder="请输入生产企业" />
        </el-form-item>
        <el-form-item label="产地" prop="caddress">
          <el-input v-model="form.caddress" placeholder="请输入产地" />
        </el-form-item>
        <el-form-item label="批准文号或注册证号" prop="cfile">
          <file-upload v-model="form.cfile"/>
        </el-form-item>
        <el-form-item label="注册商标" prop="clabel">
          <el-input v-model="form.clabel" placeholder="请输入注册商标" />
        </el-form-item>
        <el-form-item label="合格证号" prop="ccheckout">
          <el-input v-model="form.ccheckout" placeholder="请输入合格证号" />
        </el-form-item>
        <el-form-item label="生产许可证号" prop="clicence">
          <el-input v-model="form.clicence" placeholder="请输入生产许可证号" />
        </el-form-item>
        <el-form-item label="是否特殊药品" prop="bspecialties">
          <el-input v-model="form.bspecialties" placeholder="请输入是否特殊药品" />
        </el-form-item>
        <el-form-item label="仓　　库" prop="cdefwarehouse">
          <el-input v-model="form.cdefwarehouse" placeholder="请输入仓　　库" />
        </el-form-item>
        <el-form-item label="最高售价" prop="ihighprice">
          <el-input v-model="form.ihighprice" placeholder="请输入最高售价" />
        </el-form-item>
        <el-form-item label="销售加成率" prop="iexpsalerate">
          <el-input v-model="form.iexpsalerate" placeholder="请输入销售加成率" />
        </el-form-item>
        <el-form-item label="价格组" prop="cpricegroup">
          <el-input v-model="form.cpricegroup" placeholder="请输入价格组" />
        </el-form-item>
        <el-form-item label="销售贡献等级" prop="coffergrade">
          <el-input v-model="form.coffergrade" placeholder="请输入销售贡献等级" />
        </el-form-item>
        <el-form-item label="发货核销顺序" prop="iofferrate">
          <el-input v-model="form.iofferrate" placeholder="请输入发货核销顺序" />
        </el-form-item>
        <el-form-item label="cMonth" prop="cmonth">
          <el-input v-model="form.cmonth" placeholder="请输入cMonth" />
        </el-form-item>
        <el-form-item label="iAdvanceDate" prop="iadvancedate">
          <el-input v-model="form.iadvancedate" placeholder="请输入iAdvanceDate" />
        </el-form-item>
        <el-form-item label="cCurrencyName" prop="ccurrencyname">
          <el-input v-model="form.ccurrencyname" placeholder="请输入cCurrencyName" />
        </el-form-item>
        <el-form-item label="cProduceAddress" prop="cproduceaddress">
          <el-input v-model="form.cproduceaddress" placeholder="请输入cProduceAddress" />
        </el-form-item>
        <el-form-item label="cProduceNation" prop="cproducenation">
          <el-input v-model="form.cproducenation" placeholder="请输入cProduceNation" />
        </el-form-item>
        <el-form-item label="cRegisterNo" prop="cregisterno">
          <el-input v-model="form.cregisterno" placeholder="请输入cRegisterNo" />
        </el-form-item>
        <el-form-item label="cEnterNo" prop="centerno">
          <el-input v-model="form.centerno" placeholder="请输入cEnterNo" />
        </el-form-item>
        <el-form-item label="cEnglishName" prop="cenglishname">
          <el-input v-model="form.cenglishname" placeholder="请输入cEnglishName" />
        </el-form-item>
        <el-form-item label="bPropertyCheck" prop="bpropertycheck">
          <el-input v-model="form.bpropertycheck" placeholder="请输入bPropertyCheck" />
        </el-form-item>
        <el-form-item label="cCommodity" prop="ccommodity">
          <el-input v-model="form.ccommodity" placeholder="请输入cCommodity" />
        </el-form-item>
        <el-form-item label="iRecipeBatch" prop="irecipebatch">
          <el-input v-model="form.irecipebatch" placeholder="请输入iRecipeBatch" />
        </el-form-item>
        <el-form-item label="cNotPatentName" prop="cnotpatentname">
          <el-input v-model="form.cnotpatentname" placeholder="请输入cNotPatentName" />
        </el-form-item>
        <el-form-item label="bPromotSales" prop="bpromotsales">
          <el-input v-model="form.bpromotsales" placeholder="请输入bPromotSales" />
        </el-form-item>
        <el-form-item label="iPlanPolicy" prop="iplanpolicy">
          <el-input v-model="form.iplanpolicy" placeholder="请输入iPlanPolicy" />
        </el-form-item>
        <el-form-item label="iROPMethod" prop="iropmethod">
          <el-input v-model="form.iropmethod" placeholder="请输入iROPMethod" />
        </el-form-item>
        <el-form-item label="iBatchRule" prop="ibatchrule">
          <el-input v-model="form.ibatchrule" placeholder="请输入iBatchRule" />
        </el-form-item>
        <el-form-item label="fBatchIncrement" prop="fbatchincrement">
          <el-input v-model="form.fbatchincrement" placeholder="请输入fBatchIncrement" />
        </el-form-item>
        <el-form-item label="iAssureProvideDays" prop="iassureprovidedays">
          <el-input v-model="form.iassureprovidedays" placeholder="请输入iAssureProvideDays" />
        </el-form-item>
        <el-form-item label="iTestStyle" prop="iteststyle">
          <el-input v-model="form.iteststyle" placeholder="请输入iTestStyle" />
        </el-form-item>
        <el-form-item label="iDTMethod" prop="idtmethod">
          <el-input v-model="form.idtmethod" placeholder="请输入iDTMethod" />
        </el-form-item>
        <el-form-item label="fDTRate" prop="fdtrate">
          <el-input v-model="form.fdtrate" placeholder="请输入fDTRate" />
        </el-form-item>
        <el-form-item label="fDTNum" prop="fdtnum">
          <el-input v-model="form.fdtnum" placeholder="请输入fDTNum" />
        </el-form-item>
        <el-form-item label="cDTUnit" prop="cdtunit">
          <el-input v-model="form.cdtunit" placeholder="请输入cDTUnit" />
        </el-form-item>
        <el-form-item label="iDTStyle" prop="idtstyle">
          <el-input v-model="form.idtstyle" placeholder="请输入iDTStyle" />
        </el-form-item>
        <el-form-item label="iQTMethod" prop="iqtmethod">
          <el-input v-model="form.iqtmethod" placeholder="请输入iQTMethod" />
        </el-form-item>
        <el-form-item label="存货分类OID" prop="jcInventoryclassoid">
          <el-input v-model="form.jcInventoryclassoid" placeholder="请输入存货分类OID" />
        </el-form-item>
        <el-form-item label="货位档案OID" prop="jcPositionoid">
          <el-input v-model="form.jcPositionoid" placeholder="请输入货位档案OID" />
        </el-form-item>
        <el-form-item label="集团大类编码" prop="jtdlbm">
          <el-input v-model="form.jtdlbm" placeholder="请输入集团大类编码" />
        </el-form-item>
        <el-form-item label="集团小类编码" prop="jtxlbm">
          <el-input v-model="form.jtxlbm" placeholder="请输入集团小类编码" />
        </el-form-item>
        <el-form-item label="集团小类代码" prop="jtxldm">
          <el-input v-model="form.jtxldm" placeholder="请输入集团小类代码" />
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <el-input v-model="form.sort" placeholder="请输入排序" />
        </el-form-item>
        <el-form-item label="使用标识" prop="sybs">
          <el-input v-model="form.sybs" placeholder="请输入使用标识" />
        </el-form-item>
        <el-form-item label="集团删除标识" prop="jtdel">
          <el-input v-model="form.jtdel" placeholder="请输入集团删除标识" />
        </el-form-item>
        <el-form-item label="集团结算代码" prop="jtjsdm">
          <el-input v-model="form.jtjsdm" placeholder="请输入集团结算代码" />
        </el-form-item>
        <el-form-item label="集团小类代码1" prop="jtxldm1">
          <el-input v-model="form.jtxldm1" placeholder="请输入集团小类代码1" />
        </el-form-item>
        <el-form-item label="焦煤财务煤种大类代码" prop="jmcwmzdldm">
          <el-input v-model="form.jmcwmzdldm" placeholder="请输入焦煤财务煤种大类代码" />
        </el-form-item>
        <el-form-item label="焦煤财务煤种代码" prop="jmcwmzdm">
          <el-input v-model="form.jmcwmzdm" placeholder="请输入焦煤财务煤种代码" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInventory, getInventory, delInventory, addInventory, updateInventory } from "@/api/basic/inventory/inventory";

export default {
  name: "Inventory",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 存货档案表格数据
      inventoryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cinvcode: null,
        cinvaddcode: null,
        cinvname: null,
        cvencode: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        cinvcode: [
          { required: true, message: "存货编码不能为空", trigger: "blur" }
        ],
        cinvaddcode: [
          { required: true, message: "存货代码不能为空", trigger: "blur" }
        ],
        cinvname: [
          { required: true, message: "存货名称不能为空", trigger: "blur" }
        ],
        cinvstd: [
          { required: true, message: "规格型号不能为空", trigger: "blur" }
        ],
        dsdate: [
          { required: true, message: "启用日期不能为空", trigger: "blur" }
        ],
        dedate: [
          { required: true, message: "停用日期不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询存货档案列表 */
    getList() {
      this.loading = true;
      listInventory(this.queryParams).then(response => {
        this.inventoryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        jcInventoryoid: null,
        cinvcode: null,
        cinvaddcode: null,
        cinvname: null,
        cinvstd: null,
        cvencode: null,
        creplaceitem: null,
        bsale: null,
        bpurchase: null,
        bself: null,
        bcomsume: null,
        bproducing: null,
        bservice: null,
        baccessary: null,
        itaxrate: null,
        iinvweight: null,
        ivolume: null,
        iinvrcost: null,
        iinvsprice: null,
        iinvscost: null,
        iinvlscost: null,
        iinvncost: null,
        iinvadvance: null,
        iinvbatch: null,
        isafenum: null,
        itopsum: null,
        ilowsum: null,
        ioverstock: null,
        cinvabc: null,
        binvquality: null,
        binvbatch: null,
        binventrust: null,
        binvoverstock: null,
        dsdate: null,
        dedate: null,
        bfree1: null,
        bfree2: null,
        cinvdefine1: null,
        cinvdefine2: null,
        cinvdefine3: null,
        iId: null,
        binvtype: null,
        iinvmpcost: null,
        cquality: null,
        iinvsalecost: null,
        iinvscost1: null,
        iinvscost2: null,
        iinvscost3: null,
        bfree3: null,
        bfree4: null,
        bfree5: null,
        bfree6: null,
        bfree7: null,
        bfree8: null,
        bfree9: null,
        bfree10: null,
        fsubscribepoint: null,
        fvagquantity: null,
        cvaluetype: null,
        bfixexch: null,
        foutexcess: null,
        finexcess: null,
        imassdate: null,
        iwarndays: null,
        fexpensesexch: null,
        btrack: null,
        bserial: null,
        bbarcode: null,
        iid: null,
        cbarcode: null,
        cinvdefine4: null,
        cinvdefine5: null,
        cinvdefine6: null,
        cinvdefine7: null,
        cinvdefine8: null,
        cinvdefine9: null,
        cinvdefine10: null,
        cinvdefine11: null,
        cinvdefine12: null,
        cinvdefine13: null,
        cinvdefine14: null,
        cinvdefine15: null,
        cinvdefine16: null,
        igrouptype: null,
        cgroupcode: null,
        ccomunitcode: null,
        casscomunitcode: null,
        csacomunitcode: null,
        cpucomunitcode: null,
        cstcomunitcode: null,
        ccacomunitcode: null,
        cfrequency: null,
        ifrequency: null,
        idays: null,
        dlastdate: null,
        iwastage: null,
        bsolitude: null,
        centerprise: null,
        caddress: null,
        cfile: null,
        clabel: null,
        ccheckout: null,
        clicence: null,
        bspecialties: null,
        cdefwarehouse: null,
        ihighprice: null,
        iexpsalerate: null,
        cpricegroup: null,
        coffergrade: null,
        iofferrate: null,
        cmonth: null,
        iadvancedate: null,
        ccurrencyname: null,
        cproduceaddress: null,
        cproducenation: null,
        cregisterno: null,
        centerno: null,
        cpackingtype: null,
        cenglishname: null,
        bpropertycheck: null,
        cpreparationtype: null,
        ccommodity: null,
        irecipebatch: null,
        cnotpatentname: null,
        pubufts: null,
        bpromotsales: null,
        iplanpolicy: null,
        iropmethod: null,
        ibatchrule: null,
        fbatchincrement: null,
        iassureprovidedays: null,
        iteststyle: null,
        idtmethod: null,
        fdtrate: null,
        fdtnum: null,
        cdtunit: null,
        idtstyle: null,
        iqtmethod: null,
        jcInventoryclassoid: null,
        jcPositionoid: null,
        jtdlbm: null,
        jtxlbm: null,
        jtxldm: null,
        sort: null,
        sybs: null,
        jtdel: null,
        jtjsdm: null,
        jtxldm1: null,
        jmcwmzdldm: null,
        jmcwmzdm: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.jcInventoryoid)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加存货档案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const jcInventoryoid = row.jcInventoryoid || this.ids
      getInventory(jcInventoryoid).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改存货档案";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.jcInventoryoid != null) {
            updateInventory(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInventory(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const jcInventoryoids = row.jcInventoryoid || this.ids;
      this.$modal.confirm('是否确认删除存货档案编号为"' + jcInventoryoids + '"的数据项？').then(function() {
        return delInventory(jcInventoryoids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('basic/inventory/inventory/export', {
        ...this.queryParams
      }, `inventory_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
